package eg.com.itiga.ui.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import eg.com.itiga.business.company.RegCompanyService;
import eg.com.itiga.business.factory.BusinessFactory;
import eg.com.itiga.ui.beans.PendingRequestsForm;


/**
 * @author Ramadanco88
 *	Load the pending requests from the DB
 */
public class LoadPendingRequestsAction extends org.apache.struts.action.Action {
    


    
    public LoadPendingRequestsAction() {
    }
    
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        PendingRequestsForm pendingRequestsForm = (PendingRequestsForm) form;
        ActionForward actionForword = null;
        
        try {
        	RegCompanyService regCompanyService = BusinessFactory.createRegCompanyService();
			
        	pendingRequestsForm.setPendingCompanies(regCompanyService.getCompanyRequests());
        	
        	actionForword = mapping.findForward("pendingRequests");
        	
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}   
		
		return actionForword;
    }

}